package com.scott.crm.clazz.service.serviceImpl;

import com.scott.crm.clazz.bean.ClazzBean;
import com.scott.crm.clazz.bean.ClazzStudentTeacherBean;
import com.scott.crm.clazz.dao.ClazzDao;
import com.scott.crm.clazz.dao.ClazzStudentTeacherDao;
import com.scott.crm.clazz.service.ClazzStudentTeacherService;
import com.scott.crm.role.dao.UserRoleDao;
import com.scott.crm.user.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/*
 * 方法描述:
 * @author: 李伟伟
 * @date: 2021/11/30 14:17
 */
@Service
public class ClazzStudentTeacherServiceImpl implements ClazzStudentTeacherService {
    @Autowired
    private ClazzDao clazzDao;


    @Autowired
    private ClazzStudentTeacherDao clazzStudentTeacherDao;

    @Autowired
    private UserDao userDao;

    @Autowired
    private UserRoleDao userRoleDao;


    @Override
    public Integer addTeacher(ClazzStudentTeacherBean clazzStudentTeacherBean) {
        clazzStudentTeacherBean.setType(0);
        int count = clazzStudentTeacherDao.selectCount(clazzStudentTeacherBean);
        if(count!=0){
            return 0;
        }
        return clazzStudentTeacherDao.insert(clazzStudentTeacherBean);
    }

    @Override
    public Integer addStudent(ClazzStudentTeacherBean clazzStudentTeacherBean) {
        clazzStudentTeacherBean.setType(1);
        int count = clazzStudentTeacherDao.selectCount(clazzStudentTeacherBean);
        if(count!=0){
            return 0;
        }
        return clazzStudentTeacherDao.insert(clazzStudentTeacherBean);
    }

    @Override
    public List<ClazzStudentTeacherBean> findClazzStudent() {
        return clazzStudentTeacherDao.findAll();
    }

    @Override
    public List<ClazzStudentTeacherBean> findClazzStudentLimit(Integer begin, Integer end) {
      return clazzStudentTeacherDao.findAllLimit(begin,end);
    }



    @Override
    public List<ClazzBean> findClazzList() {
       return clazzDao.selectAllClazz();
    }
}
